package net.zjitc.link;

import net.zjitc.domain.Student;

public class LinkDemo {
    public static void main(String[] args) {

        //构造一个链表
        int size= 0;
        Node<Student> first =  new Node<Student>(new Student("01","A"));
        Node<Student> last = first;
        size++;

        last.next = new Node<Student>(new Student("02","B"));
        last =last.next;
        size++;

        last.next = new Node<Student>(new Student("03","C"));
        last =last.next;
        size++;

        last.next = new Node<Student>(new Student("04","C"));
        last =last.next;
        size++;


        last.next = new Node<Student>(new Student("05","C"));
        last =last.next;
        size++;


        //转置
        Node<Student> before = null;
        Node<Student> p = first;
        Node<Student> after = null;

        while (p!=null){
            after = p.next;
            p.next = before;
            before = p;
            p = after;
        }
        last = first;
        first = before;

    }
}
